<?php 
require_once('dao/OffreInternetDao.php');
if ($_SESSION['niveauAuth']=='1'or $_SESSION['niveauAuth']=='3' or $_SESSION['niveauAuth']=='4'or $_SESSION['niveauAuth']=='7'or $_SESSION['niveauAuth']=='8') {
/**
 * Controleur pour la creation d'offre achat mobile 
 */
	
	
//création d'une nouvelle offre adsl
if (isset($_POST['creation']))
{
$requete = $bdd->prepare("INSERT INTO `ve_offre_adsl` (`id`, `code_article`, `nom`, `prix`,`pv0m`, `pv12m`, `pv24m`, `pv36m`,`pv48m`) VALUES ('', '".$_POST['code_article']."', '".$_POST['nom']."','".$_POST['prix']."','".$_POST['pv0m']."','".$_POST['pv12m']."','".$_POST['pv24m']."','".$_POST['pv36m']."','".$_POST['pv48m']."') ");
			
			$requete->execute() or exit(print_r($bdd->errorInfo()));

	
	// Redirection vers la page 
	if ($_POST['action'] == "creation"){
			// Pas de changement de page
			$success=true;
	} else if ($_POST['action'] == "ve-offre-internet-creation"){
			header("Location:ve-offre-voip-creation.php?success=true");
	} else if ($_POST['action'] == "ve-offre-internet"){
		header("Location:ve-offre-internet.php?success=true");
	}
}

//$twig = new Twig_Environment($loader, array(
 //   'debug' => true,
//)); 
//$twig->addExtension(new Twig_Extension_Debug());
// a afficher dans le html: {{ debug() }}

echo $twig->render('ve-offre-internet-creation.html');

}
else {
	redirect("home-admin");
}
